<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8" > </meta>
    <title>socket</title>
    <script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
    <script src="//cdn.jsdelivr.net/sockjs/0.3.4/sockjs.min.js"></script>
    <script src="http://localhost:8000/hello/static/vertx-web-3.2.1-client.js"></script>
    <!--<script type="text/javascript">-->
       <!--$(document).ready(function () {-->
           <!--$("#content").html("adsss");-->
           <!--var sock = new SockJS('http://localhost:8080/socket');-->
           <!--sock.onopen = function() {-->
               <!--console.log('open');-->
           <!--};-->
           <!--sock.onmessage = function(e) {-->
               <!--console.log('message', e.data);-->
               <!--$("#content").html(e.data);-->
               <!--sock.close();-->
           <!--};-->
           <!--sock.onclose = function() {-->
               <!--console.log('close');-->
           <!--};-->

           <!--sock.send('test');-->


       <!--});-->
    <!--</script>-->
</head>
<body>

<div class="news">Latest news:</div>
<br />

<div id="status" class="news"></div>

<script th:inline="javascript">
    /*<![CDATA[*/
    var contextPath =/*[[${context.get('Context-Path')}]]*/ '';
    var context = /*[[${contextPath == ""? "/" + contextPath:""}]]*/ '';
    var eb = new EventBus("http://localhost:8000/hello/eventbus");
    eb.onopen = function () {
        eb.registerHandler("news-feed", function (err, msg) {
            var str = "<code>" + msg.body + "</code><br  />";
            $('#status').prepend(str);
        })
    }
    /*]]>*/
</script>

</body>
</html>